export const serverIP = `http://scm.szwego.cn:9015`
// export const serverIP = 'http://218.17.52.194:15211'
import axios from './axios'
import Cache from '../utils/cache'
import history from '../router/history'

export const LOGIN = '/Scm/Account/AntLogin'
//系统参数
export const GET_USER_MENU = '/Home/GetTreeByAnt'
export const GET_SYS_CATEGORYS = '/Scm/Dict/GetSysCategory'
export const GET_BANDS = '/scm/Dict/GetBand'
export const GET_COOPER = '/Scm/Dict/CooperationDict'//
export const GET_CENTER_CATEGORY = '/Scm/Dict/GetCenterCategory'//center分类
export const GET_MIN_CATEGORY = '/Scm/Dict/GetMinCategory'//min分类
export const GET_BASE_INFO = '/Scm/Dict/QueryBaseInfoList'//基本信息列表
export const GET_ERP_SHOP = '/Scm/Dict/GetErpShop'//店面列表
export const GET_VENDER_LIST = '/scm/Dict/GetVender'//供应商列表
export const GET_EXPName_LIST = '/Scm/YYCXSH/ExpList'//快递公司列表
export const GET_BUYER_LIST = '/Scm/Dict/QueryBuyerList'//买手列表
export const GET_STATUS_LIST = '/Scm/Dict/QueryFlagTree'
export const GET_reSTATUS_LIST = '/Scm/YYZPSH/GetBaseFalg'//样衣一审状态
export const GET_LAYOUT_LIST = '/Scm/Dict/QueryBaseInfoList'//信心指数列表
export const GET_STYLE_LIST = '/Scm/Dict/GetFGCategory'
export const GET_DICT_LIST = '/Scm/YYESTJ/GetDict'
export const GET_THDEMAND_LIST = '/VScm/BDXQ/QueryBDXQList'
export const GET_THDEMAND_BY_ID = '/Scm/Band/Get'
export const CREATE_SAMPLE = '/VScm/YYSQ/Create'
export const EDIT_SAMPLE = '/VScm/YYSQ/Edit'
export const SUBMIT_SAMPLE = '/VScm/YYSQ/Submit'
export const GET_SUPPLIER_INFO = '/VScm/GYSBase/Get'
export const GET_SCM_BAND_LIST = '/Scm/Band/QueryList'
export const CREATE_BAND = '/Scm/Band/Create'
export const UPDATE_BAND = '/Scm/Band/Edit'
export const CHECK_BAND = '/Scm/Band/Check'
export const CHECK_BANDS = '/Scm/Band/Checks'
export const DELETE_BAND = '/Scm/Band/Delete'
export const DELETE_BANDS = '/Scm/Band/Deletes'
export const GET_BAND_BY_ID = '/Scm/Band/Get'
export const GET_TYPE_PARAM_LIST = '/Scm/Dict/QueryReplenSptypeList'
export const GET_COLOR_PARAM_LIST = '/Scm/Dict/QueryReplenColourList'
export const GET_Season_PARAM_LIST = '/Scm/Dict/QueryReplenSeasonList'
export const GET_Size_PARAM_LIST = '/Scm/Dict/QueryReplenSizeList'
export const GET_Shopgrade_PARAM_LIST = '/Scm/Dict/QueryReplenShopgradeList'
export const GET_SupplierStyle_LIST = '/Scm/Dict/QueryVenderCategoryList'
export const GET_Fabric_LIST = '/Scm/Dict/QueryCategoryFabricList'
export const GET_DataPermission_LIST = '/Scm/Dict/GetUserRole'
export const CREATE_TYPE_PARAM = '/Scm/Dict/CreateReplenSptype'
export const EDIT_TYPE_PARAM = '/Scm/Dict/EditReplenSptype'
export const DELETE_TYPE_PARAM = '/Scm/Dict/DeleteReplenSptype'
export const CREATE_COLOR_PARAM = '/Scm/Dict/CreateReplenColour'
export const EDIT_COLOR_PARAM = '/Scm/Dict/EditReplenColour'
export const DELETE_COLOR_PARAM = '/Scm/Dict/DeleteReplenColour'
export const CREATE_SEASON_PARAM = '/Scm/Dict/CreateReplenSeason'
export const EDIT_SEASON_PARAM = '/Scm/Dict/EditReplenSeason'
export const DELETE_SEASON_PARAM = '/Scm/Dict/DeleteReplenSeason'
export const CREATE_SIZE_PARAM = '/Scm/Dict/CreateReplenSize'
export const EDIT_SIZE_PARAM = '/Scm/Dict/EditReplenSize'
export const DELETE_SIZE_PARAM = '/Scm/Dict/DeleteReplenSize'
export const CREATE_SHOPGRADE_PARAM = '/Scm/Dict/CreateReplenShopgrade'
export const EDIT_SHOPGRADE_PARAM = '/Scm/Dict/EditReplenShopgrade'
export const DELETE_SHOPGRADE_PARAM = '/Scm/Dict/DeleteReplenShopgrade'
export const CREATE_SUPPLIERSTYLE_PARAM = '/Scm/Dict/CreateVenderCategory'
export const EDIT_SUPPLIERSTYLE_PARAM = '/Scm/Dict/EditVenderCategory'
export const DELETE_SUPPLIERSTYLE_PARAM = '/Scm/Dict/DeleteVenderCategory'
export const CREATE_FABRIC_PARAM = '/Scm/Dict/CreateCategoryFabric'
export const EDIT_FABRIC_PARAM = '/Scm/Dict/EditCategoryFabric'
export const DELETE_FABRIC_PARAM = '/Scm/Dict/DeleteCategoryFabric'
export const CREATE_DATAPERMISSION_PARAM = '/Scm/Dict/CreateUserRole'
export const EDIT_DATAPERMISSION_PARAM = '/Scm/Dict/EditUserRole'
export const DELETE_DATAPERMISSION_PARAM = '/Scm/Dict/DeleteUserRole'
export const GET_GOODS_INFO_LIST = '/Scm/Sample/QueryGoodsInfo'
export const GET_APPLY_LIST = '/VScm/YYSQ/QueryYYSQList'
export const GET_SAMPLE_INFO = '/Scm/Sample/Get'
export const GET_WORK_STATUS = '/VScm/YYSQ/GetWrokStatus'
export const GET_SAMPLE_IMGS = '/Scm/YYZPSH/QuerySampleImg'
export const GET_CHECK_LIST = '/Scm/YYZPSH/QueryCheckList'
export const GET_SAMPLE_SCORE = '/Scm/YYYSJC/GetScore'
export const GET_getHxjcfq = '/SCM/Sample/Hxjcfq'
export const GET_ROLE_SCORE = '/Scm/YYYSJC/GetRoleScore'
export const GET_YYHXJX = '/Scm/YYHXJC/QueryYYHXJC'
export const GET_SCM_Primary_LIST = '/VScm/YYCXD/QueryYYCXDList'
export const GET_Primary_BY_ID = '/VScm/YYCXD/GetExpressDetial'
export const SEND_SAMPLE = '/VScm/YYCXD/SendSample'
export const GET_COLORS = '/Scm/Dict/GetColor'
export const GET_SIZES = '/Scm/Dict/GetSize'
export const SUBMIT_DETAIL = '/VScm/YYCXD/SubmitDetial'
export const GET_ELIMINATE_LIST = '/VScm/TTYY/QueryTTYYList'
export const TAKE_SAMPLE = '/VScm/TTYY/TakeSample'
export const GET_SECONDINSTANCE_LIST = '/VScm/ESZLBC/QueryESZLBCList'
export const EDIT_SECONINS_INFO = '/VScm/ESZLBC/Edit'
export const ONE_PHASE_API = '/DataWay/Get'
export const ONE_PHASE_API_POST = '/DataWay/Post'
export const GET_CKPHOTO_LIST = '/Scm/YYZPSH/QueryYYZPSHList'
export const CHECK_PHOTO = '/Scm/YYZPSH/CheckPhoto'
export const DELETE_PHOTO = '/SCM/Sample/DeleteSample'
export const GET_PHOTO_CHECK_LIST = '/Scm/Dict/QueryPhotoCheckList'
export const GET_PUSH_LIST = '/Scm/HXFB/QueryHXFBList'
export const PUSH_SAMPLE = '/Scm/HXFB/Publish'
export const GET_AUDITION_LIST = '/Scm/YYHX/QueryYYHXList'
export const AUDITION_UNLIKE = '/Scm/YYHX/UnLike'
export const AUDITION_LIKE = '/Scm/YYHX/Like'
export const CLOSE_AUDITION = '/Scm/YYHX/ChangeStatus'
export const GET_RESOLVE_LIST = '/Scm/YYHXJC/QueryYYHXJCList'
export const CREATE_SAMPLE_BILL = '/Scm/YYHXJC/GenBill'
export const ELIMINATE_SAMPLE = '/Scm/YYHXJC/Eliminate'
export const GET_SUPPLIER_LIST = '/Scm/MSQR/QueryMSQRList'
export const GET_BUYERCONFIRM_LIST = '/Scm/MSQR/QueryMSQRImgList'
export const BUYER_CONFIRM = '/Scm/MSQR/BuyerCheck'
export const GET_TAKEGOODS_LIST = '/Scm/YYCXSH/QueryYYCXSHList'
export const TAKE_PRIMARY_SAMPLE = '/Scm/YYCXSH/TakeSample'
export const TAKE_ONE_SAMPLE = '/Scm/YYCXSH/TakeOneSample'
export const GET_ONECHECK_LIST = '/Scm/YYYSDF/QueryYYYSDFList'
export const GET_SCORE_LIST = '/Scm/Dict/GetScoreItem'
export const SUBMIT_MARK = '/Scm/YYYSDF/SubmitMark'
export const GET_SAMPLE_MARKS = '/Scm/YYYSDF/GetMark'
export const GET_ONE_RESOLVE_LIST = '/Scm/YYYSJC/QueryYYYSJCList'
export const SUBMIT_RESOLVE = '/Scm/YYYSJC/Submit'
export const GET_OUT_LIST = '/Scm/YSTT/QueryTTYYList'
export const SEND_OUT_SAMPLE = '/Scm/YSTT/SendSample'
export const GET_OUT_SAMPLE_EXPERESS = '/Scm/YSTT/GetExpressDetial'
export const SUBMIT_OUT_EXPRESS = '/Scm/YSTT/SubmitDetial'
export const GET_CHECKSTYLE_LIST = '/YYFGQR/QueryYYFGQRList'
export const CHECK_STYLE = '/YYFGQR/Edit'
export const GET_INSTANCE_BY_ID = '/Scm/Cost/GetBySampleId'
export const SUBMIT_COST = '/Scm/Cost/SubmitCost'
export const GET_DATACHECK_LIST = '/Scm/SHXPZL/QuerySHXPZLList'
export const DATA_CHECK = '/Scm/SHXPZL/DataCheck'
export const GET_SECORD_SUBMIT_LIST = '/Scm/YYESTJ/QueryYYESTJList'
export const GET_SECORD_SUBMIT_BY_ID = '/Scm/YYESTJ/GetDetial'
export const SUBMIT_TMARK = '/Scm/YYESTJ/SubmitTmark'
export const CREATE_TMARK_DATA = '/Scm/YYESTJ/GenData'
export const GET_PUSH_GOODS_DATA = '/Scm/YYESTJ/QueryPHSJListByProc'
export const SUBMIT_TMARK_DATA = '/Scm/YYESTJ/Submit'
export const GET_TYPE_INFO_LIST = '/Scm/YYESTJ/QueryPLSJFXByProc'
export const GET_DATA_PIC_LIST = '/Scm/YYESTJ/QueryTPKList'
export const GET_MANAGER_APPROVAL_LIST = '/Scm/CGJLSP/QueryCGJLSPList'
export const GET_SECORD_APPROVAL_LIST = '/Scm/YYESSP/QueryYYESSPList'
export const SUBMIT_MANAGER_APPROVAL = '/Scm/CGJLSP/SubmitList'
export const SECORD_SUBMIT = '/Scm/YYESSP/SubmitList'
export const GET_REASON_LIST = '/Scm/YYESSP/GetReason'
//用户登录
export const api_login = data => {
  return get(LOGIN, data)
}
export const exportExcel = (url, data) => {
  window.location.href = `${getUrl(url)}&${data}`
}
//get请求
export const get = (url, data)=> {
  const config = {
    method: 'GET',
    url: getUrl(url),
    params: data
  }
  return request(config)
}

//post请求
export const post = (url, data)=> {
  const config = {
    method: 'post',
    url: getUrl(url),
    data: data
  }
  return request(config)
}
const request = (config)=> {
  return new Promise((resole,reject)=>{
    axios(config).then( response => {
      var res = response.data
      if(res.code == '401') history.replace({pathname: '/login'})
      else resole(res)
    }).catch( response => {
      console.log('网络不通！', response)
    })
  })
}
const getUrl = url => {
  let token = ''
  if(Cache.sessionGet('LOGIN_USER')) token = Cache.sessionGet('LOGIN_USER').token
  return `${serverIP}${url}?token=${token}`
} 